
<script type="text/javascript">

$(function(){
		   
	$('#formVoce').ajaxForm({
		dataType: 'json',
		beforeSubmit: function() {			
			if( $("#formVoce").validate().form()==false )
			return false;
		},
		success: function(responseText, statusText) {
			if(responseText.sucesso){
				$.jAlert(responseText.mensagem, '', function(result) {
					listaDados();
					window.location = '/?pg=home';
				});
			}else{
				$.jAlert(responseText.mensagem, '');
			}
		}

	})
	
	listaDados();
	
	function buscaImagensPessoal(pessoa_id){
		$.ajax({
			type:"POST",
			url:"actions/listaImagensPessoalAction.php",
			data:{pessoa_id:pessoa_id},
			dataType:"json",
			success: function(data, textStatus, request){
				$("#fotoPessoa").html(data['imagem']);	
			}	
		});
	}

	function listaDados(){
		$.ajax({
			type:"POST",
			url:"actions/voceAction.php",
			dataType:"json",
			success: function(data, textStatus, request){
				$("#txtNome").val(data['nome']);
				$("#txtSobrenome").val(data['sobrenome']);
				$("#txtNascimento").val(data['nascimento']);
				$("#txtSexo").val(data['sexo']);	
				$("#txtFacebook").val(data['facebook']);
				$("#txtWebPage").val(data['webpage']);
				$("#txtTwitter").val(data['twitter']);
				$("#txtEmail").val(data['email']);
				$("#txtIdPessoa").val(data['id_pessoa']);
				$("#txtFacebook").val(data['facebook']);
				$("#txtwebpage").val(data['webpage']);
				
				$("#lkFacebook").attr("href",'http://'+data['facebook']);
				$("#lkTwitter").attr("href",'http://'+data['twitter']);	
				$("#lkEmail").attr("href",'mailto:'+data['email']);	
			    $("#lksite").attr("href",'http://'+data['webpage']);			
			
				buscaImagensPessoal(data['id_pessoa']);
				
				if(data['sexo']=="M"){
					$("#sexo_m").html("<input type='radio' id='txtSexo' checked='checked' name='txtSexo' value='M'/>");	
					$("#sexo_f").html("<input type='radio' id='txtSexo' name='txtSexo' value='F'/>");
				}else{
					$("#sexo_m").html("<input type='radio' id='txtSexo' name='txtSexo' value='M'/>");	
					$("#sexo_f").html("<input type='radio' id='txtSexo'  checked='checked' name='txtSexo' value='F'/>");	
				}
				
				$("#icone").html("<img src='images/IconesTempo/"+data['icon']+".png' />");
				
				//carrega o componente mudar senha
				$("#cpMudarSenha").load("componentes/mudarSenha.php?id="+data['id_pessoa']);
				
				//carrega o componente ler mensagens
				$("#cpLerMensagens").load("componentes/lerMensagens.php?id="+data['id_pessoa']);
				
				//carrega o componente novo video info
				$("#cfInseriVideo").load("componentes/insereVideo.php?id="+data['id_pessoa']);
				
				//busca disciplinas do combo
				$("#txtDisciplina1id").load("actions/ajaxlistarDisciplinasComboAction.php?disciplina_id="+data['disciplina1']);
				
				//busca disciplinas do combo
				$("#txtDisciplina2id").load("actions/ajaxlistarDisciplinasComboAction.php?disciplina_id="+data['disciplina2']);
				
				//busca disciplinas do combo
				$("#txtSala").load("actions/ajaxlistarSalasComboAction.php?sala_id="+data['sala_id']);
				
				//busca disciplinas do combo
				$("#txtEsporteId").load("actions/ajaxlistarEsporteComboAction.php?esporte_id="+data['esporte_id']);
				
				//carrega o componente novo video info
				$("#cfMudaImagem").load("componentes/mudaImagem.php?id="+data['id_pessoa']);
				
			}	
		});
	}
	
	$("#content").css("height","550px");
	
	$("#txtNascimento").mask("99/99/9999");
	

})	

function postarVideo(){	

	$('#info_video').dialog({show: "blind",
								hide: "explode",
								width:400,
								height:200,
								resizable:false}); 
}

function lerMensagens(){	
	$('#abri_msg').dialog({show: "blind", hide: "explode", width:500, height:440, resizable:false}); 
}

function mudarSenha(){
	$('#mudar_senha').dialog({show: "blind", hide: "explode", width:532, height:240, resizable:false});
}

function comoEstou(estado){
	$.ajax({
		type:"POST",
		data:{estado:estado},
		url:"actions/comoEstouAction.php",
		dataType:"json",
		success: function(data, textStatus, request){
			$("#icone").html("<img src='images/IconesTempo/"+data['icon']+".png' />");
			$('#tipos').hide();	
		}	
	});
}

function mostraTipos(){
	$('#tipos').show();	
}

function escondeTipos(){
	$('#tipos').hide();		
}


function mudarFoto(){
	$('#abri_imagem').dialog({show: "blind", hide: "explode", width:500, height:200, resizable:false}); 	
}

</script>

<style>

	a{color:#333;}

</style>

<div id="formularios">

<div style="position:absolute;width:90px;height:90px;left:610px;top:70px;" id="icone" title="Clique para Mudar" ondblclick="mostraTipos();"></div>

<div style="position:absolute;width:74px;height:168px;left:620px;top:160px;text-align:center;display:none;background-image:url(images/fundoComoEstou.png);" id="tipos">

	<div style="padding-left:58px;"><a href="javascript:void(0)" onclick="escondeTipos();"><div style="height:20px;width:20px;"></div></a></div>
    
	<div style="margin-top:5px;">
	<a href="javascript:void(0)" onclick="comoEstou('ChuvaSol');"><img src="images/IconesTempo/ChuvaSol_p.png" title="Vai Melhorar" height="25" width="25"/></a>
    <a href="javascript:void(0)" onclick="comoEstou('ChuvasTrovoadas');"><img src="images/IconesTempo/ChuvasTrovoadas_p.png" title="Nervoso(a)" height="25" width="25"/></a>
    <br />
    <a href="javascript:void(0)" onclick="comoEstou('Chuvoso');"><img src="images/IconesTempo/Chuvoso_p.png" title="Chuvoso" height="25" width="25"/></a>
    <a href="javascript:void(0)" onclick="comoEstou('Enluarado');"><img src="images/IconesTempo/Enluarado_p.png" title="Está Piorando" height="25" width="25"/></a>
    <br />
    <a href="javascript:void(0)" onclick="comoEstou('Ensolarado');"><img src="images/IconesTempo/Ensolarado_p.png" title="Misterioso" height="25" width="25"/></a>
    <a href="javascript:void(0)" onclick="comoEstou('MuitoQuente');"><img src="images/IconesTempo/MuitoQuente_p.png" title="Fervendo" height="25" width="25"/></a>
    <br />
    <a href="javascript:void(0)" onclick="comoEstou('Nebuloso');"><img src="images/IconesTempo/Nebuloso_p.png" title="Confuso" height="25" width="25"/></a>
    <a href="javascript:void(0)" onclick="comoEstou('Nevando');"><img src="images/IconesTempo/Nevando_p.png" title="Frio(a)" height="25" width="25"/></a>
    <br />
    <a href="javascript:void(0)" onclick="comoEstou('ParcialNublado');"><img src="images/IconesTempo/ParcialNublado_p.png" title="Mais ou Menos" height="25" width="25"/></a>
    <a href="javascript:void(0)" onclick="comoEstou('Nublado');"><img src="images/IconesTempo/Nublado_p.png" title="Entediado" height="25" width="25"/></a>
    </div>
</div>

<fieldset style="height:440px;width:800px;padding:10px;">
        <legend>
            <img src="../images/topoPaginas/Icon_Voce_Menu.png"/>
        </legend>
        <div id="btnSairForms">
        <a href="/?pg=home" title="Sair" style="border:0;">
        	<img src="images/btnOutros/btnSairForms.png"/>
        </a>
        </div>
        <div style="padding-left:80px;padding-top:25px;"> 
        
        <form action="actions/voceAction.php" method="post" id="formVoce" name="formVoce">
        	<table width="640" border="0">
              <tr>
                <td colspan="3">
                	<span id="title">Primeiro Nome</span><span style="color:#F00;">*</span><br />
                    <input name="txtNome" type="text" class="required"  id="txtNome" size="40" maxlength="40"/>
                    <input type="hidden"  id="acao" name="acao" value="edit"/>
                    <input type="hidden"  id="txtIdPessoa" name="txtIdPessoa"/>
                </td>
                <td width="139">&nbsp;</td>
                <td width="188" rowspan="4" align="center" valign="middle">
                
                	<div style="background:url(images/btnOutros/fundoFoto.png);width:83px;height:82px;">
                    	<span id="fotoPessoa"></span>
                    </div>
                    <span><a href="javascript:void(0);" onclick="mudarFoto()" style="color:#000;font-size:10px;">Alterar Foto</a></span>               
                	
                </td>
                <td width="43" rowspan="4" align="center" valign="middle">&nbsp;</td>
              </tr>
              <tr>
                <td width="144">&nbsp;</td>
                <td width="59">&nbsp;</td>
                <td width="41">&nbsp;</td>
                <td align="center"><span id="title">Sexo</span></td>
              </tr>
              <tr>
                <td colspan="3">
                  <span id="title">Sobrenome</span><span style="color:#F00;">*</span><br />
                  <input name="txtSobrenome" type="text" class="required"  id="txtSobrenome" size="40" maxlength="40"/>
                </td>
                <td><table width="139" height="31" border="0">
                  <tr>
                    <td width="65" align="center">
                    <label>	
                        <span id="sexo_m"></span>
                        <img src="images/btnOutros/masculino.png" title="Masculino"/>
                    </label>
                    </td>
                    <td width="64" align="center">
                    <label>
                        <span id="sexo_f"></span>
                        <img src="images/btnOutros/feminino.png" title="Feminino"/>
                    </label>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td colspan="2" align="left">&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="6"><table width="633" border="0">
                  <tr>
                    <td width="171">
                    <span id="title">Nascimento</span><br />
                    <input type="text"  id="txtNascimento" name="txtNascimento" class="exibeData"/>
                    </td>
                    <td width="158">
                    <span id="title">Esporte Favorito</span><br />
                 	<select id="txtEsporteId" name="txtEsporteId">
                        <option>Selecione</option>
                    </select>  
                    </td>
                    <td width="158">
					<?php if($_SESSION['tipo_pessoa']=="P"){ ?>
                        <span id="title">Disciplina 1</span><br />
                        <select id="txtDisciplina1id" name="txtDisciplina1id">
                            <option>Selecione</option>
                        </select>
                    <?php }else{ ?>
                        <span id="title">Sala</span><br />
                        <select id="txtSala" name="txtSala">
                            <option>Selecione</option>
                        </select>
                    <?php } ?>
                    </td>
                    <td width="128">
					<?php if($_SESSION['tipo_pessoa']=="P"){ ?>
                        <span id="title">Disciplina 2</span><br />
                        <select id="txtDisciplina2id" name="txtDisciplina2id">
                            <option>Selecione</option>
                        </select>
                    <?php } ?>
                    </td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2"><span id="title">WebPage</span><br />
                <input name="txtWebPage" type="text"  id="txtWebPage" size="30" maxlength="30"/>
                </td>
                <td><a href="#" id="lksite" title="Home" style="border:0;"><img src="images/btnOutros/btnHome.png" height="22" width="22"/></a></td>
                <td>&nbsp;</td>
                <td><span id="title">E-mail</span><br />
                <input name="txtEmail" type="text"  id="txtEmail" size="30"/></td>
                <td><a href="#" id="lkEmail" title="E-mail" style="border:0;"><img src="images/btnOutros/btnEmail.png" height="22" width="22"/></a></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2"><span id="title">Twitter</span><br />
                <input name="txtTwitter" type="text"  id="txtTwitter" size="30" maxlength="30"/>
                </td>
                <td><a href="#" id="lkTwitter" title="Twitter" target="_blank" style="border:0;"><img src="images/btnOutros/btnTwitter.png" height="22" width="22"/></a></td>
                <td>&nbsp;</td>
                <td><span id="title">Facebook</span><br />
                <input name="txtFacebook" type="text"  id="txtFacebook" size="30" maxlength="30"/></td>
                <td><a href="#" id="lkFacebook" title="Facebook" style="border:0;"><img src="images/btnOutros/btnFacebook.png" height="22" width="22"/></a></td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2">&nbsp;</td>
                <td></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
            </table>

           </form> 
      </div>
    </fieldset>
    
    <div style="position:relative;width:800px;height:40px;text-align:right;padding-right:10px;font-size:10px;color:#F00;">
    	* Campos de preenchimento Obrigatório    
    </div>
    
    <div style="position:relative;width:800px;height:40px;text-align:center;">
    	<a href="javascript:void(0);" onclick="lerMensagens();" title="Ler Mensagem" style="border:0;text-decoration:none;">
            <img src="images/btnOutros/btnLerMensagem.png"/>
        </a>
    	<a href="javascript:void(0);" onclick="mudarSenha();" title="Mudar Senha" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnMudarSenha.png"/>
        </a>
    	<a href="javascript:void(0);" onclick="postarVideo();" title="Postar Video" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnPostarVideo.png" />
        </a>
    	<a href="javascript:void(0);" title="Salvar Alterações" onclick="$('#formVoce').submit()" style="border:0;text-decoration:none;padding-left:12px;">
            <img src="images/btnOutros/btnSalvar.png" />
        </a>
    </div>

</div>


<!-- -----------Fala Professor Componente------------- -->
<div id="cpLerMensagens" style="display:none;"></div>
<!-- -----------Fala Professor Componente------------- -->

<!-- -----------Fala Professor Componente------------- -->
<div id="cpMudarSenha" style="display:none;"></div>
<!-- -----------Fala Professor Componente------------- -->

<!-- -----------insere video Componente------------- -->
<div id="cfInseriVideo" style="display:none;"></div>
<!-- -----------insere video Componente------------- -->

<!-- -----------insere imagem Componente------------- -->
<div id="cfMudaImagem" style="display:none;"></div>
<!-- -----------insere imagem Componente------------- -->